package com.cisetech.web.bobocai.houtai;


import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.cisetech.service.LCustomerMessageService;
import com.cisetech.vo.Page;
import com.cisetech.vo.bobocai.LCustomerMessage;

//留言控制器
@Controller
@RequestMapping(value="/book")
public class BookController {
	@Autowired
	LCustomerMessageService customerMessageService;
	Logger log = LoggerFactory.getLogger(BookController.class);
	
	@RequestMapping(value="",method=RequestMethod.GET)
	public ModelAndView index(HttpServletResponse response,HttpServletRequest request){
		ModelAndView v = new ModelAndView("houtai/book");
		return v;
	}
	@ResponseBody
	@RequestMapping(value="getList",method=RequestMethod.POST)
	public Page<LCustomerMessage> getList(LCustomerMessage customerMessage,HttpServletResponse response,HttpServletRequest request){
		Page<LCustomerMessage> page = customerMessageService.getList(customerMessage);
		return page;
	}
	//删除留言
	@ResponseBody
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	public String  deleteAdv(LCustomerMessage customerMessage,HttpServletRequest request,HttpServletResponse response){
		int i=0;//成功
		try {
			customerMessageService.delete(customerMessage.getCustomerMessage());
		} catch (Exception e) {
			log.debug(e.getLocalizedMessage());
			i=1;//失败
		}
		System.out.println(i);
		return i+"";
	}
}
